Version=$(shell git describe --tags --abbrev=0)
GitCommit=$(shell git rev-parse HEAD)
BuildDate=$(shell date +"%F %T")
debug=-w -s
param=-X main.VERSION=${Version} -X main.BUILD_GIT_HASH=${GitCommit} -X 'main.BUILD_TIME=${BuildDate}'

.PHONY: help
help: ## 帮助信息
	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.PHONY: build
build: ## 交叉构建
	go build -ldflags "${debug} ${param}" -o bin/tfwrapper

.PHONY: install
install: build ## 安装
	@cp bin/tfwrapper /Users/haiker/Applications/hashicorp/bin

.PHONY: build-all
build-all:
	CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "${debug} ${param}" -o bin/tfwrapper-linux-amd64
